local juanxia = fk.CreateSkill{
    name = "wk_heg__juanxia"
}

Fk:loadTranslationTable{
    ["wk_heg__juanxia"] = "狷狭",
    [":wk_heg__juanxia"] = "结束阶段，你可选择一名其他角色，视为对其使用一张【杀】，然后其可对你发起“军令”，若你不执行，其对你造成1点伤害。",

    ["#wk_heg__juanxia-choose"] = "狷狭：你可选择一名其他角色，视为对其使用一张【杀】",

    ["$wk_heg__juanxia1"] = "汝有何功，竟能居我之上！",
    ["$wk_heg__juanxia2"] = "恃才傲立，恩怨必偿。",
}

local H = require "packages/ol_hegemony/util"

juanxia:addEffect(fk.EventPhaseStart,{
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
  return player:hasSkill(juanxia.name) and target == player and player.phase == Player.Finish and 
    player:canUse(Fk:cloneCard("slash"), { bypass_distances = false, bypass_times = true })
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local targets = {}
    local slash = Fk:cloneCard("slash")
    for _, p in ipairs(room:getOtherPlayers(player)) do
      if not player:isProhibited(p, slash) then
        table.insert(targets, p)
      end
    end
    local tos = room:askToChoosePlayers(player,{
      targets = targets,
      min_num = 1,
      max_num = 1,
      prompt = "#wk_heg__juanxia-choose",
      skill_name = juanxia.name,
      cancelable = true,
    })
    if #tos > 0 then
      event:setCostData(self,{ tos = tos })
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    room:useVirtualCard("slash", nil, player, to, juanxia.name, true)
    local choices = {"start_command", "Cancel"}
    if not to.dead and room:askToChoice(to, {choices = choices, skill_name = juanxia.name}) == "start_command" and not H.askCommandTo(to, player, juanxia.name) then
      room:damage{
        from = to,
        to = player,
        damage = 1,
        skillName = juanxia.name,
      }
    end
  end,
})

return juanxia
